package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.service.WorkerspaceService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.OrderOverViewVO;
import com.sky.vo.SetmealOverViewVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

@Slf4j
@RestController
@RequestMapping("/admin/workspace")
public class WorkspaceController {
    @Autowired
    private WorkerspaceService workerspaceService;

    /**
     * 获取营业数据
     * @return
     */
    @GetMapping("/businessData")
    public Result<BusinessDataVO> businessRate(){
        log.info("工作台获取营业数据");
        LocalDate begin = LocalDate.now();
        LocalDate end = LocalDate.now();
        LocalDateTime beginTime = LocalDateTime.of(begin, LocalTime.MIN);
        LocalDateTime endTime = LocalDateTime.of(end, LocalTime.MAX);
        BusinessDataVO businessDataVO = workerspaceService.getBusinessData(beginTime,endTime);
        return Result.success(businessDataVO);
    }

    /**
     * 获取订单统计数据
     * @return
     */
    @GetMapping("/overviewOrders")
    public Result<OrderOverViewVO> overviewOrders(){
        log.info("工作台获取订单统计数据");
        OrderOverViewVO orderOverViewVO = workerspaceService.getOverviewOrders();
        return Result.success(orderOverViewVO);
    }


    /**
     * 获取套餐统计数据
     * @return
     */
    @GetMapping("/overviewSetmeals")
    public Result<SetmealOverViewVO> overviewSetmeals(){
        log.info("工作台获取套餐统计数据");
        SetmealOverViewVO setmealOverViewVO = workerspaceService.getSetmealOverview();
        return Result.success(setmealOverViewVO);
    }

    /**
     * 获取菜品统计数据
     * @return
     */
    @GetMapping("/overviewDishes")
    public Result<DishOverViewVO> overviewDishes(){
        log.info("工作台获取菜品统计数据");
        DishOverViewVO dishOverViewVO = workerspaceService.getDishOverview();
        return Result.success(dishOverViewVO);
    }
}
